{% extends "base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% load ietf_filters ipr_filters static person_filters textfilters %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
{% endblock %}
{% block title %}History for IPR - {{ ipr.title }}{% endblock %}
{% block content %}
    {% origin %}
    <h1>
        History for IPR disclosure
        <br>
        <small class="text-body-secondary">{{ ipr.title }}</small>
    </h1>
    {% include "ipr/details_tabs.html" %}
    {% if user|has_role:"Area Director,Secretariat,IANA,RFC Editor" %}
        <p class="buttonlist">
            <a class="btn btn-primary"
               href="{% url 'ietf.ipr.views.add_comment' id=ipr.id %}"
               title="Add comment to history">
                Add comment
            </a>
            <a class="btn btn-primary"
               href="{% url 'ietf.ipr.views.add_email' id=ipr.id %}"
               title="Add email to history">
                Add email
            </a>
        </p>
    {% endif %}
    <table class="table table-sm table-striped tablesorter">
        <thead>
            <tr>
                <th scope="col" data-sort="date">Date</th>
                <th scope="col" data-sort="type">Type</th>
                <th scope="col" data-sort="by">By</th>
                <th scope="col" data-sort="text">Text</th>
            </tr>
        </thead>
        {% if events %}
            <tbody>
                {% for e in events %}
                    <tr id="history-{{ e.pk }}">
                        <td>{{ e.time|date:"Y-m-d" }}</td>
                        <td>
                            {{ e.type }}
                            {% if e.response_due and e.response_past_due %}
                                <i class="bi bi-exclamation-circle" title="Response overdue"></i>
                            {% endif %}
                        </td>
                        <td>{% person_link e.by %}</td>
                        <td class="text-break">
                            {% if e.message %}
                                {% if e.response_due %}<span class="badge rounded-pill text-bg-info">Response due {{ e.response_due|date:"Y-m-d" }}</span>{% endif %}
                                {# FIXME: can't do format_history_text, because that inserts a <div> into the <pre>, which is illegal. Need to rework the snippeting. #}
                                <pre>{{ e.message|render_message_for_history|urlize_ietf_docs|linkify }}</pre>
                            {% else %}
                                {{ e.desc|format_history_text }}
                            {% endif %}
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        {% endif %}
    </table>
{% endblock %}
{% block js %}
    <script src="{% static "ietf/js/list.js" %}"></script>
{% endblock %}
